package com.vvlive.caibao.smartcity.ui;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;

import com.vvlive.caibao.smartcity.adapter.LifeOrderMealCanTpingjiaAdapter;
import com.vvlive.caibao.smartcity.base.BaseActivity;
import com.vvlive.caibao.smartcity.bean.LifeOrderMealStoreBean;
import com.vvlive.caibao.smartcity.utils.CallPhone;
import com.vvlive.caibao.smartcity.utils.MyRefreshListener;
import com.vvlive.caibao.smartcity.view.CommonActionBar;
import com.vvlive.caibao.smartcity.view.PullToRefreshLayout;
import com.vvlive.caibao.smartcity.view.PullableListView;

import java.util.ArrayList;
import java.util.List;

import smartcity.vvlive.caibao.com.smartc.R;

/**
 * Created by lenovo on 2015/7/4.
 * 找餐厅详情页
 */
public class LifeRestaurantActivity extends BaseActivity {
    LifeOrderMealStoreBean mMealStoreBean;
    PullableListView mPullableListView;
    List<LifeOrderMealStoreBean> mBeanList = new ArrayList<>();
    //餐厅名
//    @BindView(id = R.id.ct_name,click = false)
    TextView mname;
    //餐厅消费范围介绍,起送价
//    @BindView(id = R.id.ct_xffw,click = false)
    TextView mxffw;
    //餐厅评星
//    @BindView(id = R.id.ct_pingxing,click = false)
    RatingBar mpx;
    //餐厅电话
//    @BindView(id = R.id.canting_dh,click = false)
    TextView mdianhua;
    //餐厅地址
//    @BindView(id = R.id.canting_dz,click = false)
    TextView mdizhi;
    //餐厅优惠活动
//    @BindView(id = R.id.canting_yhhd,click = false)
    TextView myouhui;
    //立即预约
//    @BindView(id = R.id.ct_ljyy,click = true)
    Button mlijiyuyue;
    //电话预定
//    @BindView(id = R.id.ct_dhyd,click = true)
    Button mdianhuayuding;
    View view;

    @Override
    protected int getContentViewRes() {
        return R.layout.refresh_list;
    }


    @Override
    public void initWidget() {
        super.initWidget();

        mMealStoreBean = (LifeOrderMealStoreBean) getIntent().getSerializableExtra("dingcan");
        CommonActionBar actionBar = super.getCommonActionBar();
        actionBar.setTitle(mMealStoreBean.getName());
        view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.life_restaurant_activity,null);

        ((PullToRefreshLayout) findViewById(R.id.pulltorefreshlayout))
                .setOnRefreshListener(new MyRefreshListener());
        mPullableListView = (PullableListView) findViewById(R.id.life_buttom_list);
        mPullableListView.addHeaderView(view);
        init();
        LifeOrderMealCanTpingjiaAdapter orderMealListAdapter = new LifeOrderMealCanTpingjiaAdapter(getApplicationContext(),mBeanList);
        mPullableListView.setAdapter(orderMealListAdapter);
        //
        mname = (TextView) view.findViewById(R.id.ct_name);
        mxffw = (TextView) view.findViewById(R.id.ct_xffw);
        mpx = (RatingBar) view.findViewById(R.id.ct_pingxing);
        mdianhua = (TextView) view.findViewById(R.id.canting_dh);
        mdizhi = (TextView) view.findViewById(R.id.canting_dz);
        myouhui = (TextView) view.findViewById(R.id.canting_yhhd);
        mlijiyuyue = (Button) view.findViewById(R.id.ct_ljyy);
        mdianhuayuding = (Button) view.findViewById(R.id.ct_dhyd);
        //名
        mname.setText(mMealStoreBean.getName());
        //餐厅消费范围介绍,起送价
        mxffw.setText(mMealStoreBean.getXffw());
        //餐厅评星
        mpx.setProgress(mMealStoreBean.getPingxing());
        //餐厅电话
        mdianhua.setText("18423828347");
        //餐厅地址
        mdizhi.setText("上海市");
        //餐厅优惠活动
        myouhui.setText("满30减15，第二份半价");
        //立即预约
        mlijiyuyue.setOnClickListener(this);
        //电话预定
        mdianhuayuding.setOnClickListener(this);
    }

    @Override
    public void widgetClick(View v) {
        super.widgetClick(v);
        switch (v.getId()){
            case R.id.ct_ljyy://立即预约
                toast("立即预约");
                CallPhone.callPhone(this,"10086");
                break;
            case R.id.ct_dhyd://电话预定
                toast("电话预定");
                CallPhone.callPhone(this, "10086");
                break;
        }
    }
    /**
     * 初始化本地数据,测试用
     * */
    private void init(){
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming, "好粥道", 3, "25元起送", 0.0, 0.0, "",13.00));
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming,"便当",4,"25元起送",0.0,0.0,"",13.00));
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming, "好运来", 1, "15元起送", 0.0, 0.0, "",13.00));
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming, "好运来", 1, "15元起送", 0.0, 0.0, "",13.00));
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming, "好粥道", 3, "25元起送", 0.0, 0.0, "",13.00));
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming, "好粥道", 3, "25元起送", 0.0, 0.0, "",13.00));
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming,"麦当劳",5,"35元起送",0.0,0.0,"",13.00));
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming, "麦当劳", 5, "35元起送", 0.0, 0.0, "",13.00));
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming, "肯德基", 4, "45元起送", 0.0, 0.0, "",13.00));
        mBeanList.add(new LifeOrderMealStoreBean(R.mipmap.dianpuming, "肯德基", 4, "45元起送", 0.0, 0.0, "",13.00));
    }
}
